import { http } from './http'
import { PageQueryParams, PageResponse } from '@/config/page'

export interface MessaageQueryParams extends PageQueryParams {
  category: 'notice' | 'at' | 'message';
}

export type MesseageCategory = 'notice' | 'at' | 'message'

/**
 * 获取消息列表
 */
export function queryMessages (params: MessaageQueryParams) {
  return http().get<PageResponse<any>>('/api/document/messages', { params })
}

/**
 * 标记为已读
 * @param ids
 * @returns
 */
export function markRead (ids: number[]) {
  return http().put<any>('/api/document/messages/mark/read', { ids })
}

/**
 * 批量删除。
 * @param ids
 * @returns
 */
export function deteteInbatch (ids: number[]) {
  return http().put<any>('/api/document/messages/delete', { ids })
}

/**
 * 按类别全部标记。
 * @param ids
 * @returns
 */
export function markReadByCategory (category: MesseageCategory) {
  return http().put<any>(`/api/document/messages/category/${category}/read`)
}

/**
 * 按类别全部删除。
 * @param category
 * @returns
 */
export function deleteAllByCategory (category: MesseageCategory) {
  return http().put<any>(`/api/document/messages/category/${category}/delete`)
}

/**
 * 获取未读数量。
 */
export function countUnread () {
  return http().get<any>('/api/document/messages/count/unread')
}
